% function testRadon3
%
% Test the functions radon3, PPFT3, and optimizedPPFT3
%
% Yoel Shkolnisky 03/02/03

function testRadon3D

eps = 1.e-11;

% Test the reference function slowPPFT3.
% According to the Fourier slice theorem for the 3-D discrete radon
% transform, the 1-D inverse FFT of the pseudo-polar Fourier transform
% (slowPPFT3) along the parameter k should be equal to the discrete 3-D 
% radon transform.
im = rand(2,2,2);
rr = slowRadon3D(im);
pp = slowPPFT3D(im);
rr2 = icfftd(pp,2);
reportResult('Test slowPPFT3',max(abs(rr(:)-rr2(:))) < eps);

% Test the function PPFT3 by comparing it to slowPPFT3 (we assume the
% slowPPFT3 was verified in the pervious step)
%im = rand(4,4,4);
im = rand(2,2,2);
pp = slowPPFT3D(im);
pp2 = PPFT3D(im);
reportResult('Test PPFT3',max(abs(pp(:)-pp2(:))) < eps);

% Test the function optimizedPPFT3 by comparing it to PPFT3.
im = rand(8,8,8);
pp = PPFT3D(im);
pp2 = optimizedPPFT3D(im);
reportResult('Test OptimizedPPFT3',max(abs(pp(:)-pp2(:))) < eps);

% Test the function Radon3 by comparing it to the reference function
% slowRadon3.
im = rand(4,4,4);
rr = slowRadon3D(im);
rr2 = radon3D(im);
reportResult('Test Radon3',max(abs(rr(:)-rr2(:))) < eps);



function reportResult(testMsg,res)
if (res)
    str = 'OK';
else
    str = 'FAIL';
end
fprintf('%s \t %s\n',testMsg,str);
